<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org"
				xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
  <meta charset="utf-8"/>
  <title>取书码校验</title>
  <link rel="stylesheet" href="/css/layui.css" media="all"/>
  <script src='/js/jquery-2.0.3.min.js'></script>
  <style>
  
  .body {
  	display:flex;
  	justify-content:center;
  	align-items: center;
  }
  	.box {
  	margin-top:50px;
  		width: 500px;
  		min-height: 500px;
  	}
  	
  	.box .layui-form-label {
  	width: 150px;
  	}
  	
  	.box .layui-btn {
  	margin-left: -5px;
  	}
  	
  	
  	#result {
  		width:100%;
  		height: 200px;
  	}
  	
  	.editDeal .layui-form-label {
  		width: 120px;
  	}
  </style>
  <script src="/layui.js"></script>
  <script>
    var layer;
    var $;
    layui.use(['layer'], function () {
    	$ = layui.jquery, layer = layui.layer;
    })
  </script>
  <script>
  /*<![CDATA[*/
  function valCode(){
  		var code = $("#code").val();
  		if(code==""){
  			layer.msg("请输入取书码！");
  			return ;
  		}
  		$("#borrowInfo :input").val("");
		$("#borrowInfo").attr("class", "form-group  layui-hide");
		$("#takeBook").hide();
  		$.ajax({
  			url:"/admin/valBookCode",
  			data:{code:code},
  			type:"POST",
  			success:function (data){
  				if(data.rspCode=='000000'){
  					$("#a-form-borrowid").val(data.data.borrowId);
  					$("#a-form-nickname").val(data.data.user.nickname);
  					$("#a-form-realname").val(data.data.user.realname);
  					$("#a-form-booknumber").val(data.data.book.booknumber);
  					$("#a-form-bookname").val(data.data.book.bookname);
  					$("#a-form-borrowtime").val(data.data.borrowTime);
  					$("#a-form-returntime").val(data.data.returnTime);
  					$("#borrowInfo").attr("class", "form-group");
  					$("#takeBook").show();
  				}else if(data.rspCode=='000110'){
  					layer.msg(data.rspMsg);
  				}else{
  					layer.msg("请联系管理员！");
  				}
  			}
  		});
  	}
  
  	function dealCode(){
  		var code = $("#code").val();
  		if(code==""){
  			layer.msg("请输入取书码！");
  			return ;
  		}
  		layer.confirm("确认取书？", function(index){
	  		$.ajax({
	  			url:"/admin/dealBookCode",
	  			data:{code:code},
	  			type:"POST",
	  			success:function (data){
	  				if(data.rspCode=="000110"||data.rspCode=="000000"){
	  					layer.close(index);
	  					layer.msg(data.rspMsg);
	  					$("#borrowInfo :input").val("");
	  					$("#borrowInfo").attr("class", "form-group  layui-hide");
	  	  				$("#takeBook").hide();
	  				}
	  			}
	  		});
  		});	
  	}
  
  /*]]>*/
  </script>
</head>
<body class="body">
<div class="box layui-form layui-form-pane">
	
      <label class="layui-form-label">请输入取书码：</label>
      <div class="layui-input-inline">
        <input class="layui-input"  id="code"/>
      </div>
      <button class="layui-btn" onclick="valCode()">查询</button>
 		<div id="result">
  			<div class="form-group  layui-hide" id="borrowInfo">
				<form class="layui-form editDeal">
				<br/>
				<fieldset class="layui-elem-field">
				  <legend>借阅信息</legend>
				  <div class="layui-field-box">
				  <div class="layui-form-item">
				    <label class="layui-form-label">借阅编号</label>
				    <div class="layui-input-inline">
				      <input type="text"  id="a-form-borrowid" name="borrowId"   class="layui-input" disabled="disabled"/>
				    </div>
				  </div>
				  <div class="layui-form-item">
				    <label class="layui-form-label">用户昵称</label>
				    <div class="layui-input-inline">
				      <input type="text"  id="a-form-nickname" name="nickname"    class="layui-input" disabled="disabled"/>
				    </div>
				  </div>
				  <div class="layui-form-item">
				    <label class="layui-form-label">真实姓名</label>
				    <div class="layui-input-inline">
				      <input type="text"  id="a-form-realname" name="realname"    class="layui-input" disabled="disabled"/>
				    </div>
				  </div>
				  <div class="layui-form-item">
				    <label class="layui-form-label">图书名称</label>
				    <div class="layui-input-inline">
				      <input type="text"  id="a-form-bookname" name="bookname"    class="layui-input" disabled="disabled"/>
				    </div>
				  </div>
				  <div class="layui-form-item">
				    <label class="layui-form-label">图书编号</label>
				    <div class="layui-input-inline">
				      <input type="text"  id="a-form-booknumber" name="booknumber"   class="layui-input" disabled="disabled"/>
				    </div>
				  </div>
				  <div class="layui-form-item">
				    <label class="layui-form-label">借阅时间</label>
				    <div class="layui-input-inline">
				      <input type="text"  id="a-form-borrowtime" name="borrowTime"    class="layui-input" disabled="disabled"/>
				    </div>
				  </div>
				  <div class="layui-form-item">
				    <label class="layui-form-label">应归还时间</label>
				    <div class="layui-input-inline">
				      <input type="text"  id="a-form-returntime" name="returnTime"     class="layui-input" disabled="disabled"/>
				    </div>
				  </div>
				  </div>
				</fieldset>
				  
				</form>  
				</div>
  	
	
	  <div class="layui-form-item">
	    <div class="layui-input-block">
	      <button class='layui-btn' onclick='dealCode()' id="takeBook" style="display: none;">确认取书</button>
	    </div>
	 </div>
	</div>
</div>
  
  
  
  

  	
  	
</body>
</html>